package com.huabo.system.controller;

import com.huabo.system.utils.HttpClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.HashMap;

@SuppressWarnings({ "unused", "rawtypes", "unchecked", "deprecation" })
@Controller
@RequestMapping(value = "/redisorg")
@Api(value="RedisController",tags={"redis组织缓存Controller"})
public class RedisOrgController extends BaseController{

	private static final Logger logger = LoggerFactory.getLogger(RedisOrgController.class);

	@Value("${insertOrgOneUrl}")
	private String insertOrgOneUrl;

	/**
	 * 更新单个公司所有信息(组织启用、禁用时使用)
	 * @param nodeId
	 * @return
	 */
	@RequestMapping(value = "/insertOrgOne", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "更新单个公司的缓存")
	public @ResponseBody String insertOrgOne(BigDecimal nodeId) {
		String str;
		HashMap<String, Object> fields = new HashMap<String, Object>();
		fields.put("nodeId",nodeId);
		try {
			str = HttpClient.request(insertOrgOneUrl, fields, null);
			return str;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}

	public String insertOrg(BigDecimal orgid) {
		String str;
		HashMap<String, Object> fields = new HashMap<String, Object>();
		fields.put("nodeId",orgid);
		try {
			return str = HttpClient.request(HttpClient.insertOrgOneUrl, fields, null);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}
}
